package com.yangwudi.mapper;


import com.yangwudi.pojo.PageResult;
import com.yangwudi.pojo.Student;
import com.yangwudi.pojo.StudentQueryParam;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {

    /**
     * 学员列表-条件分页查询
     */
    List<Student> list(StudentQueryParam studentQueryParam);


    /**
     * 根据ID批量删除学员信息
     */

    void deleteByIds(List<Integer> ids);


    /**
     * 添加学员信息
     */
    void addStudent(Student student);


    /**
     * 查询回显 - 根据主键ID查询学员的信息
     */
    @Select("select *  from student where id = #{id}")
    Student getById(Integer id);


    /**
     * 修改学员信息
     */
    void update(Student student);

    /**
     * 违纪处理
     */
    void handleViolation(Integer id, Integer violationScore);

    /**
     * 统计学员学历信息
     */
    @MapKey("name")
    List<Map<String, Object>> getStudentDegreeData();

    /**
     * 班级人数统计
     */
    @MapKey("name")
    List<Map<String, Object>> getStudentCountData();

    /**
     * 根据班级ID查询班级人数
     */
    @Select("select count(*) from student inner join clazz c on student.clazz_id = c.id where c.id = #{is}")
    int countStudentByClazzId(Integer id);
}

